package controllers

import (
	"blog_api/models"
	"github.com/gin-gonic/gin"
	"strconv"
	"strings"
)

type PowerController struct {
	BaseController
}

/**
 * PowerList
 * @Description: 后台的左侧菜单tree
 * @Author: Jazk-Z
 * @receiver u
 * @param c
 */
func (p PowerController) PowerList(c *gin.Context) {
	ptree := models.PowerTree()
	p.success(c, "success", ptree)
	return
}

func (p PowerController) AdminPowerList(c *gin.Context) {
	keyword := strings.TrimSpace(c.DefaultQuery("keyword", ""))
	page, _ := strconv.Atoi(c.DefaultQuery("page", "1"))
	limit, _ := strconv.Atoi(c.DefaultQuery("limit", "10"))
	offset := (page - 1) * limit

	models.AdminPowerList(limit, offset, keyword)
}
